<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <form action="">
            <div>
                用户名：
                <input type="text" v-model="uname" v-on:keyup.delete="clearContent">
            </div>
            <div>
                密码：
                <input type="text" v-model="pwd" v-on:keyup.enter="handleSubmit">
            </div>
            <div>
                <input type="button" v-on:click="handleSubmit"  value="提交">
            </div>
        </form>
    </div>
    <script>
        /*
        .enter回车键
            <input v-on:keyup.enter='submit'>
        .delete删除键
            <input v-onkeyup.delete="handle">
        */
        var vm = new Vue({
            el:'#app',
            data:{
               uname:'',
               pwd:''
            },
            methods:{
                handleSubmit:function(){
                   console.log(this.uname,this.pwd);
                },
                clearContent:function(){
                    //按delete键的时候，清空用户名
                    this.uname='';
                }
            }
        });
    </script>
</body>
</html>